
assert(PandaDKPMaster, "PandaDKPMaster not found!")

------------------------------
--      Are you local?      --
------------------------------
local dew = AceLibrary("Dewdrop-2.5")
local PandaDKPMaster = PandaDKPMaster

----------------------------
--      FuBar Plugin      --
----------------------------

PandaDKPMaster:SetFuBarOption("tooltipType", "GameTooltip")
PandaDKPMaster:SetFuBarOption('cannotDetachTooltip', true)
PandaDKPMaster:SetFuBarOption('hasNoColor', false)
PandaDKPMaster:SetFuBarOption("iconPath", [[Interface\Buttons\UI-GroupLoot-Dice-Up]])


-----------------------------
--      FuBar Methods      --
-----------------------------

function PandaDKPMaster:OnFuBarClick(self, button)
	if button == "RightButton" then
		dew:Open(self,
			"children", function()
				dew:FeedAceOptionsTable(PandaDKPMaster.cmdtable)
			end
		)
	else
	   InterfaceOptionsFrame_OpenToCategory("Panda DKP Master")
	end
end

function PandaDKPMaster:OnUpdateFuBarTooltip()
	GameTooltip:AddLine("Panda DKP Master")
   GameTooltip:AddLine("|cffeda55fClick|r to show configuration options.", 0.2, 1, 0.2)
end


----------------------------
--      LDB Plugin      --
----------------------------

local ldb = LibStub("LibDataBroker-1.1"):NewDataObject("PandaDKPMaster", {
	type = "launcher",
	text = "Panda DKP Master",
	icon = "Interface\\Buttons\\UI-GroupLoot-Dice-Up",
})


-----------------------------
--      LDB Methods      --
-----------------------------

function ldb.OnClick(self, button)
	if button == "RightButton" then
		dew:Open(self,
			"children", function()
				dew:FeedAceOptionsTable(PandaDKPMaster.cmdtable)
			end
		)
	else
	   InterfaceOptionsFrame_OpenToCategory("Panda DKP Master")
	end
end

function ldb.OnTooltipShow(tt)
	tt:AddLine("Panda DKP Master")
   tt:AddLine("|cffeda55fClick|r to show configuration options.", 0.2, 1, 0.2)
end


-- Addon options tables
PandaDKPMaster.options = {}


-- Options table for the fubar menu
PandaDKPMaster.cmdtable =
{
   type = 'group',
	handler = PandaDKPMaster,
   args =
   {
      showloot =
      {
         type = 'execute',
         name = 'Loot Distribution...',
         desc = 'Show the dialog to handle bids and distribute loot.',
         func = function() PandaDKPMaster.Looting:ShowLootDistribution() end,
         order = 10
      },
      pubnaxx =
      {
         type = 'execute',
         name = 'Publish DKP to guild...',
         desc = 'Broadcasts the DKP of every player to the guild.',
         func = function() PandaDKPMaster.Players:PublishDKPToGuild() end,
         order = 11
      },
   }
}